//
//  UserSetUpCell.m
//  CheekiOS
//
//  Created by mac on 2017/6/22.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserSetUpCell.h"

@interface UserSetUpCell ()

@property (nonatomic, strong)UILabel *nameLab;

@property (nonatomic, assign)NSIndexPath *indexPath;
@property (nonatomic, strong)UILabel *topLin;
@property (nonatomic, strong)UILabel *bottomLin;
@property (nonatomic, strong)UILabel *linLab;
@end

@implementation UserSetUpCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath*)indexPath {
    static NSString *UserSetUpCellIdent = @"UserSetUpCellIdent";
    UserSetUpCell *cell = [tableView dequeueReusableCellWithIdentifier:UserSetUpCellIdent];
    if (!cell) {
        cell = [[UserSetUpCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserSetUpCellIdent];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    cell.indexPath = indexPath;
    if (indexPath.row == 3 || indexPath.row == 6) {
        cell.accessoryType = UITableViewCellAccessoryNone;
        
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.nameLab = [UILabel new];
        self.nameLab.textColor = [UIColor blackColor];
        self.nameLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.nameLab];
        
        self.cacheLab = [UILabel new];
        self.cacheLab.textColor = RGB(178, 178, 178);
        self.cacheLab.textAlignment = NSTextAlignmentRight;
        [self addSubview:self.cacheLab];
        
        self.topLin = [UILabel new];
        self.topLin.backgroundColor = RGB(243, 243, 243);
        [self addSubview:self.topLin];
        
        self.bottomLin = [UILabel new];
        self.bottomLin.backgroundColor = RGB(243, 243, 243);
        [self addSubview:self.bottomLin];
        
        self.linLab = [UILabel new];
        self.linLab.backgroundColor = RGB(243, 243, 243);
        [self addSubview:self.linLab];
        
    }
    
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    if (_indexPath.row == 0 || _indexPath.row == 3 || _indexPath.row == 6) {
        if (_indexPath.row == 6) {
            self.topLin.frame = CGRectMake(0, 0, KScreenWidth, 10);
            self.nameLab.frame = CGRectMake(0, 10, KScreenWidth, self.height-10);
        }else{
            self.topLin.frame = CGRectMake(0, 0, KScreenWidth, 10);
            self.nameLab.frame = CGRectMake(15, 10, KScreenWidth/2, self.height-20);
            self.bottomLin.frame = CGRectMake(0, self.nameLab.bottom, KScreenWidth, 10);
        }

    }else{
        self.nameLab.frame = CGRectMake(15, 0, KScreenWidth/2, self.height);
    }
    
    if (_indexPath.row == 1 || _indexPath.row == 4 ) {
        self.linLab.frame = CGRectMake(0, self.nameLab.bottom-1, KScreenWidth, 1);
    }
    
    if (_indexPath.row == 3) {
        self.cacheLab.frame = CGRectMake(self.nameLab.right, 0, KScreenWidth/2-45, self.height);
    }
    
    
    if (_indexPath.row == 0) {
        self.nameLab.text = @"账号与安全";
    }else if (_indexPath.row == 1){
        self.nameLab.text = @"黑名单";

    }else if (_indexPath.row == 2){
        self.nameLab.text = @"处罚名单";

    }else if (_indexPath.row == 3){
        self.nameLab.text = @"清除缓存";
        

    }else if (_indexPath.row == 4){
        self.nameLab.text = @"关于我们";

    }else if (_indexPath.row == 5){
        self.nameLab.text = @"帮助与反馈";

    }else{
        self.nameLab.text = @"退出";
        self.nameLab.textAlignment = NSTextAlignmentCenter;

    }
    
    
    
}


@end
